<template>
  <view :class="'grid col-'+colNum">
  	<view :class="'text-center '+[showPadding=='2'?'padding':'']" @click="jumpPage" :data-jumpUrl="item.jumpUrl" :data-jumpType="item.jumpType" v-for="(item,index) in list" :key="index">
      <view class="base-font-34 text-bold base-color-2" :style="'position: relative;height:'+listHeight+';width:'+listWidth+'; margin:0px auto;'">
        {{item.text}}
      </view>
      <text v-if="item.name!=null && item.name!=''" :style="'line-height:'+textLineHeight+';'" >{{item.name}}</text>
    </view>
  </view>
</template>
<script>
  export default{
    data(){
      return {
        listHeight:'80upx',
        listWidth:'auto',
		textLineHeight:'30upx',
        list:[],
      }
    },
    props:{
		//审核类型：1、不审核，2、审核不通过，弹窗提示，3、审核不通过，跳转页面
		checkType:{
		  type:String,
		  default(){
		    return "1"
		  }
		},
		checkPage:{
		  type:String,
		  default(){
		    return "/pages/my/my"
		  }
		},
      showPadding:{
        type:String,
        default(){
          return "2"
        }
      },
      textHeight:{
        type:String,
        default(){
          return uni.upx2px(30)+'px';
        }
      },
	  height:{
	    type:String,
	    default(){
	      return uni.upx2px(80)+'px';
	    }
	  },
      width:{
        type:String,
        default(){
          return ""
        }
      },
      colNum:{
        type:String,
        default(){
          return "3"
        }
      },
      btnList:{
        type:Array
      }
    },
    watch: {
      btnList:{
        handler(newValue, oldValue) {  
          this.list=newValue;
        },
        deep:true
      }
    },
    mounted() {
      this.list=this.btnList;
	  this.textLineHeight=uni.upx2px(this.textHeight)+'px';
      this.listHeight=uni.upx2px(this.height)+'px';
      if(this.width!=null&&this.width!=""&&this.width!='undefined'){
        this.listWidth=uni.upx2px(this.width)+'px';
      }else{
        this.listWidth='auto';
      }
    },
    methods:{
      jumpPage(e) {
		let type=true;
		if(this.checkType!="1"){
			//验证
			let token=uni.getStorageSync('token');
			if(token==null||token==""){
				type=false;
			}
		}
		if(type){
			var jumpType=e.currentTarget.dataset.jumptype;
			var jumpurl=e.currentTarget.dataset.jumpurl;
			if(jumpurl!=null&&jumpurl!=""){
			  if(jumpType==1){
			   uni.redirectTo({
			   	url:jumpurl,
			   })
			  }else{
			    uni.navigateTo({
			    	url:jumpurl,
			    })
			  }
			}
		}else if(this.checkType=="2"){
			uni.showModal({
				title: '',
				content:'请先登录/注册',
			    showCancel:false,
				success: function(res) {
				}
			});
		}else if(this.checkType=="3"){
			uni.redirectTo({
				url:this.jumpPage,
			})
		}
      }
    }
  }
  
</script>


